package jp.co.hcs.attendancemanagement.inputtableb.logic;

import java.sql.SQLException;

import jp.co.hcs.attendancemanagement.data.dao.ProjectDAO;
import jp.co.hcs.attendancemanagement.data.entity.Project;
import jp.co.hcs.attendancemanagement.logic.LogicBase;

/**
 * The Class CheckProjectCodeLogic.
 */
public class CheckProjectCodeLogic extends LogicBase {

  /** The check project code logic. */
  private static CheckProjectCodeLogic checkProjectCodeLogic = new CheckProjectCodeLogic();

  /** The project dao. */
  private ProjectDAO projectDAO;

  /**
   * Gets the single instance of CheckProjectCodeLogic.
   * 
   * @return single instance of CheckProjectCodeLogic
   */
  public static CheckProjectCodeLogic getInstance() {
    return checkProjectCodeLogic;
  }

  /**
   * Check project code existing.
   * 
   * @param inputProjectCode the input project code
   * @param inputSeri the input seri
   * @return the project
   * @throws SQLException the sQL exception
   */
  public Project checkProjectCodeExisting(String inputProjectCode, String inputSeri)
      throws SQLException {
    Project project = getProjectDAO().selectProjectByPrimaryKey(inputProjectCode + inputSeri);
    return project;
  }

  /**
   * Gets the project dao.
   * 
   * @return the project dao
   */
  public ProjectDAO getProjectDAO() {
    if (projectDAO == null) {
      projectDAO = daoFactory.getProjectDAO();
    }

    return projectDAO;
  }

  /**
   * Sets the project dao.
   * 
   * @param projectDAO the new project dao
   */
  public void setProjectDAO(ProjectDAO projectDAO) {
    this.projectDAO = projectDAO;
  }

}
